/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package SYSGEST.br.Setor;

import sysgest.conexao.HibernateUtil;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author AELSON
 */
public class SetorDAO {
    
    private Session sessao;
    private Transaction transacao;

    public void salvar(Setor setor) {
        sessao = HibernateUtil.getSessionFactory()
                .openSession();
        transacao = sessao.beginTransaction();
        sessao.save(setor);
        transacao.commit();
        sessao.close();
    }
    
  public List<Setor> listarSetor1s() {
        sessao = HibernateUtil.getSessionFactory()
                .openSession();
        transacao = sessao.beginTransaction();
        List<Setor> listarSet
                = sessao.createCriteria(Setor.class).list();
        sessao.close();
        return listarSet;

    }
}
